package unitTests;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.Before;
import org.junit.Test;

import datamodels.Conference;
import datamodels.GlobalDataStore;

/**
 *test GlobalData
 * @author anthonysierra
 *
 */
public class GlobalDataStoreTest {
	GlobalDataStore my_data_store;
	@Before
	public void instantiate()
	{
		my_data_store = new GlobalDataStore();
	}
	
	@Test
	public void constructorTest() {
		//First get all the conferences and perform sanity check that the test conference
		//is not already in the store.
		GlobalDataStore store = new GlobalDataStore();
		List<Conference> conferences_before = store.getConferences();
		Conference test_con = new Conference("Example");
		store.removeConferenceObject(test_con);
		assertFalse(conferences_before.contains(test_con));
		
		//Then add the test conference to the store
		try {
			store.addConferenceObject(test_con);
		} catch (Exception e) { }
		
		//Fetch all the conferences from the data store once again.
		GlobalDataStore second_store = new GlobalDataStore();
		List<Conference> conferences_after = second_store.getConferences();
		
		assertEquals(conferences_after.size(), conferences_before.size());
		for (int i=0; i<conferences_after.size(); i++) {
			boolean contains = false;
			for (int j=0; j<conferences_before.size(); j++) {
				if (conferences_before.get(j).getName().equals(conferences_after.get(i).getName())) contains = true;
				
			}
			assertTrue(contains);
		}
	}
	

}
